Enterprise Objects Framework Release 1.1 Copyright ã1995 by NeXT Computer, Inc.  All Rights Reserved.

NXTableDataSources
(informal protocol)

Category Of:	Object

Declared In:	eointerface/NXTableProtocols.h

Category Description

The NXTableDataSources protocol declares methods used by an NXTableView and its formatters to access the values in the table view's data source. A data source must be able to report how many rows or columns it contains and to retrieve or set a value for a given row and column, where either rows or columns represent properties.

Note:  An NXTableView's data source is an object that implements methods of the this category, and is not the sort of data source defined by the EODataSources protocol. In fact, for an NXTableView used with an EOController the data source is an EOColumnAssociation.

An individual value in a data source is typically specified by an identifier and a position for that identifier, though it can also be specified by two identifiers. An identifier is an object that indicates which property of the table view's data source is displayed in a vector. The data source uses an identifier to access the appropriate value when an NXFormatter needs to draw or edit a field. The nature of the identifier is completely up to the data source; it isn't used by the table view or the table vector.

For example, a data source can define its identifiers as NSStrings naming the properties it provides, such as ªlastNameº, ªcityº, and so on. It can records the values for these properties as NSDictionary objects in an NSArray, and which it access by the position requested:

- getValueFor:identifier at:(unsigned int)position into:aValue
{
    id theValue;

    theValue = [[values objectAtIndex:position]
        objectForKey:identifier];

    if (!theValue) [aValue setString:@""];
    [aValue setString:theValue];

    return self;
}

The data source using this implementation of getValueFor:at:into: has an NSMutableArray called values whose elements are NSDictionary objects with property names for keys. The value passed in conforms to the NXTableValue protocol (even though it's not declared as such), and that the values maintained by the data source are assumed to be NSStrings.

Method Types

Reporting table size	- rowCount
- columnCount

Getting/setting data	- getValueFor:at:into:
- getValueFor::into:
- setValueFor:at:from:
- setValueFor::from:

Instance Methods

columnCount

- (unsigned int)columnCount

Returns the number of columns in the data source. If the data source is set up for a static column this is 1; if it's set up for a static row, this is the number of records in the data source.

See also:  - rowCount

getValueFor::into:

- getValueFor:rowIdentifier
:columnIdentifier
into:aValue

Copies the value of an attribute from the data source into the object aValue (an object conforming to the NXTableValue protocol). The record value to retrieve is specified by the property identifiers rowIdentifier and columnIdentifier, and not by position. Returns self.

Specifying record values by identifier and not position is useful when you don't want to depend on an array-like ordering of records. For example, a data source can use rowIdentifier as a primary key for its records and columnIdentifier as a property identifier.

See also:  - getValueFor:at:into:

getValueFor:at:into:

- getValueFor:identifier
at:(unsigned int)aPosition
into:aValue

Copies the value of an attribute from the data source into the object aValue (an object conforming to the NXTableValue protocol). The record value to retrieve is specified by the property identifier identifier and by aPosition, which gives the index within the data source for the value. Returns self.

See also:  - getValueFor::into:

rowCount

- (unsigned int)rowCount

Returns the number of rows in the data source. If the data source is set up for a static row this is 1; if it's set up for a static column, this is the number of records in the data source.

See also:  - columnCount

setValueFor::from:

- setValueFor:rowIdentifier
:columnIdentifier
from:aValue

Sets the value of a record's attribute in the data source to the value contained in aValue (an object conforming to the NXTableValue protocol). The record value to modify is specified by the property identifiers rowIdentifier and by columnIdentifier, which gives the index within the data source for the value. Returns self.

Specifying record values by identifier and not position is useful when you don't want to depend on an array-like ordering of records. For example, a data source can use rowIdentifier as a primary key for its records and columnIdentifier as a property identifier.

See also:  - setValueFor:at:from:

setValueFor:at:from:

- setValueFor:identifier
at:(unsigned int)aPosition
from:aValue

Sets the value of a record's attribute in the data source to the value contained in aValue (an object conforming to the NXTableValue protocol). The record value to modify is specified by the property identifier identifier and by aPosition, which gives the index within the data source for the value. Returns self.

See also:  - setValueFor::from: